#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 2e5 + 10, INF = 0x3f3f3f3f;

int n = 0;
vector<int> g[N];
int d[N],dis[N];
bool st[N];

void solve()
{
    for (int i = 0;i <= n;i++) g[i].clear();
    memset(st, 0, sizeof st);
    memset(d, 0, sizeof d);
    cin >> n;
    for (int i = 1;i < n;i++) {
        int x, y; cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        d[x]++, d[y]++;
    }

    int mx = 0;
    queue<int> q;
    for (int i = 1;i <= n;i++)  if (d[i] == 1) { q.push(i);st[i] = 1;dis[i] = 0; }
    while (!q.empty()) {
        int x = q.front();q.pop();
        for (int y : g[x]) {
            if (st[y] == 1) continue;
            dis[y] = dis[x] + 1;
            mx = max(mx, dis[y]);
            q.push(y);
            st[y] = 1;
        }
    }

    vector<int> ans;
    for (int i = 1;i <= n;i++)
        if (dis[i] == mx) ans.push_back(i);

    cout << ans.size() << '\n';
    for (int it : ans) cout << it << ' ';
    cout << '\n';
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    cin >> T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}